# Recipe file for stumpwm.
#
# Maintainers: (C) 2017 Mateus P. Rodrigues, mprodrigues@dragora.org.
#
# Under the terms of the GNU General Public License.

program=stumpwm
version=1.0.0
release=1

description="
StumpWM is a tiling, keyboard driven X11 Window Manager written entirely in Common Lisp.
"

homepage=https://stumpwm.github.io/index.html
license=GPLv2

tarname=${version}.tar.gz

# Remote source(s)
fetch=https://github.com/stumpwm/stumpwm/archive/$tarname

# Parallel jobs for the compiler
jobs=1

pkgname=stumpwm

# Source documentation
docs="AUTHORS COPYING HACKING NEWS README.md"
docsdir="${docdir}/${program}-${version}"

build() {
    unpack "${tardir}/$tarname"

    cd "$srcdir"

    ./autogen.sh
    ./configure $configure_args \
    --with-lisp=clisp \
    --build=${ARCH}-dragora-linux-gnu

    make -j${jobs} install DESTDIR="$destdir"

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if [ -d "${destdir}/$mandir" ] ; then
	(
            cd "${destdir}/$mandir"
	    find . -type f -exec lzip -9 '{}' +
	    find . -type l | while read -r file
	    do
		ln -sf "$(readlink -- "$file").lz" "${file}.lz"
		rm -- "$file"
	    done
	)
    fi

    # Copy documentation
    mkdir -p "${destdir}${docsdir}"

    for file in $docs ; do
            cp -p $file "${destdir}${docsdir}"
	        done
}
